package tech.runchen.gz5055.oms.modules.system.service.impl;

import tech.runchen.gz5055.oms.modules.system.entity.UserNoticeEntity;
import tech.runchen.gz5055.oms.modules.system.mapper.UserNoticeMapper;
import tech.runchen.gz5055.oms.modules.system.service.IUserNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户通知表 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-11-13
 */
@Service
public class UserNoticeServiceImpl extends ServiceImpl<UserNoticeMapper, UserNoticeEntity> implements IUserNoticeService {

    @Override
    public void saveOrUpdate(Long noticeId, List<Long> userIdList) {
        if (userIdList == null || userIdList.size() == 0) {
            return;
        }
        //保存用户与通知关系
        for (Long userId : userIdList) {
            UserNoticeEntity userNotice = new UserNoticeEntity();
            userNotice.setUserId(userId);
            userNotice.setNoticeId(noticeId);
            this.save(userNotice);
        }
    }

    @Override
    public List<Long> queryNoticeIdList(Long userId) {
        return baseMapper.queryNoticeIdList(userId);
    }

    @Override
    public int deleteBatch(Long[] noticeIds) {
        return baseMapper.deleteBatch(noticeIds);
    }
}
